﻿using System.Collections.Generic;

namespace BlogAPIUnitTest
{
    using BlogsAPI;
    using BlogsAPI.Sites;
    using System;
    using BlogsAPI.Abstract;
    using System.Diagnostics;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Проверим оставление сообщений во всех сервисах
    /// </summary>
    [TestClass]
    public class HowManyReadersTest
    {
        private static void RunTest(BlogServer bs, String username, BlogType bt)
        {
            uint? res = bs.HowManyReaders(username,bt);
            Assert.AreNotEqual(null,res);
            Assert.IsTrue(res > 0);
            Debug.WriteLine(String.Format("В системе {0} для пользователя {1} найдено {2} читателей",
                bs.GetType().Name,username,res.ToString()));
        }

        [TestMethod]
        public void LjReaders()
        {
            //RunTest(new Livejournal(), "blond-in-co", BlogType.User);
            RunTest(new Livejournal(), "gloriaputina", BlogType.User);
            RunTest(new Livejournal(), "modern_crusader", BlogType.User);
            RunTest(new Livejournal(), "ru_medvedev", BlogType.Community);
            RunTest(new Livejournal(), "msk_arenda", BlogType.Community);
        }

        
        [TestMethod]
        public void LiRuReaders()
        {
            RunTest(new Liveinternet(), "flashr", BlogType.User);
            RunTest(new Liveinternet(), "www.valez.ru", BlogType.User);
            RunTest(new Liveinternet(), "topbot.ru", BlogType.User);
            RunTest(new Liveinternet(), "4210962", BlogType.User);
        }

        //YaRu closed
        //[TestMethod]
        //public void YaRuReaders()
        //{
        //    RunTest(new YaRu(), "flashr", BlogType.User);
        //    RunTest(new YaRu(), "webmaster", BlogType.User);
        //    RunTest(new YaRu(), "company", BlogType.Community);
        //    RunTest(new YaRu(), "4611686018427402148", BlogType.Community);
        //}

        [TestMethod]
        public void BlogsMailReaders()
        {
            RunTest(new BlogsMail(), "tikandelaki", BlogType.User);
            RunTest(new BlogsMail(), "mail", BlogType.User);
            RunTest(new BlogsMail(), "vrs63", BlogType.User);
        }

        [TestMethod]
        public void DiaryReaders()
        {
            RunTest(new Diary(), "10350", BlogType.User);
            RunTest(new Diary(), "akinakai", BlogType.User);
            RunTest(new Diary(), "blizzard", BlogType.User);
        }

        [TestMethod]
        public void GooglePlusReaders()
        {
            var gp = new GooglePlus();
            string userid = "107317115324835515107";
            var data = gp.HowManyReaders(userid, BlogType.User);
            //gp.HowManyReaders("101945292797147744663", BlogType.User, out isBP);

            RunTest(new GooglePlus(), "111931627441418090108", BlogType.User);
            RunTest(new GooglePlus(), "111000835266298743697", BlogType.User);
            RunTest(new GooglePlus(), "101299173996475709329", BlogType.User);
        }


        [TestMethod]
        public void GoogleFriendsList()
        {
            GooglePlus gp = new GooglePlus();
            bool isBP;
            Dictionary<string,string[]> oRes =  gp.GetFriendsList("111931627441418090108");
        }

        [TestMethod]
        public void TwitterReaders()
        {
            RunTest(new Twitter(), "putin2012", BlogType.User);
        }

        [TestMethod]
        public void YoutubeReaders()
        {
            RunTest(new YouTube(), "wwwt30pru", BlogType.User);
        }
    }
}
